//
//  ToothView.swift
//  DentalFormula
//
//  Created by AMalashin on 23.09.2023.
//

import SwiftUI

struct ToothView: View {
    var tooth: Tooth?

    var body: some View {
        Rectangle()
            .strokeBorder(lineWidth: 1)
            .aspectRatio(1.0, contentMode: .fit)
            .overlay(alignment: .center) {
                ZStack {
                    if let tooth = tooth {
                        if let condition = tooth.condition {
                            Text(condition.localized())
                        } else {
                            Text(tooth.number.description)
                        }
                    } else {
                        Text("·")
                    }
                }
                .font(.system(size: 300))
                .minimumScaleFactor(0.01)
            }
    }
}

#Preview("English Localization") {
    ToothView(tooth: Tooth(number: 11, condition: .decayFilling))
        .environment(\.locale, .init(identifier: "en"))
}

#Preview("Russian Localization") {
    ToothView()
        .environment(\.locale, .init(identifier: "ru"))
}
